package MicroSpring.common;

import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class PoinCutDefinition {
    private boolean isPointCut;
    private boolean isAround;
    private boolean isBefore;
    private boolean isAfter;

    private boolean isTargetClass;
    private boolean isTargetMethod;


    private String packageName;
    private String modifiersPattern;
    private String retTypePpattern;
    private String declaringTypePattern;
    private String namePattern;
    private String paramPattern;
    private String throwsPattern;
    private String annoName;

    private Method[] methods;
    private Method method;

    private boolean isTargetToPointCut;
    private String targetPointCutMethodName;

    private final Map<Class,Method[]> classMethods=new ConcurrentHashMap<>();


    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public boolean isAround() {
        return isAround;
    }

    public void setAround(boolean around) {
        isAround = around;
    }

    public boolean isBefore() {
        return isBefore;
    }

    public void setBefore(boolean before) {
        isBefore = before;
    }

    public boolean isAfter() {
        return isAfter;
    }

    public void setAfter(boolean after) {
        isAfter = after;
    }

    public boolean isPointCut() {
        return isPointCut;
    }

    public void setPointCut(boolean pointCut) {
        isPointCut = pointCut;
    }

    public String getAnnoName() {
        return annoName;
    }

    public void setAnnoName(String annoName) {
        this.annoName = annoName;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getModifiersPattern() {
        return modifiersPattern;
    }

    public void setModifiersPattern(String modifiersPattern) {
        this.modifiersPattern = modifiersPattern;
    }

    public String getRetTypePpattern() {
        return retTypePpattern;
    }

    public void setRetTypePpattern(String retTypePpattern) {
        this.retTypePpattern = retTypePpattern;
    }

    public String getDeclaringTypePattern() {
        return declaringTypePattern;
    }

    public void setDeclaringTypePattern(String declaringTypePattern) {
        this.declaringTypePattern = declaringTypePattern;
    }

    public String getNamePattern() {
        return namePattern;
    }

    public void setNamePattern(String namePattern) {
        this.namePattern = namePattern;
    }

    public String getParamPattern() {
        return paramPattern;
    }

    public void setParamPattern(String paramPattern) {
        this.paramPattern = paramPattern;
    }

    public String getThrowsPattern() {
        return throwsPattern;
    }

    public void setThrowsPattern(String throwsPattern) {
        this.throwsPattern = throwsPattern;
    }

    public boolean isTargetClass() {
        return isTargetClass;
    }

    public void setTargetClass(boolean targetClass) {
        isTargetClass = targetClass;
    }

    public boolean isTargetMethod() {
        return isTargetMethod;
    }

    public void setTargetMethod(boolean targetMethod) {
        isTargetMethod = targetMethod;
    }

    @Override
    public String toString() {
        return "PoinCutDefinition{" +
                "isTargetClass=" + isTargetClass +
                ", isTargetMethod=" + isTargetMethod +
                ", packageName='" + packageName + '\'' +
                ", modifiersPattern='" + modifiersPattern + '\'' +
                ", retTypePpattern='" + retTypePpattern + '\'' +
                ", declaringTypePattern='" + declaringTypePattern + '\'' +
                ", namePattern='" + namePattern + '\'' +
                ", paramPattern='" + paramPattern + '\'' +
                ", throwsPattern='" + throwsPattern + '\'' +
                ", annoName='" + annoName + '\'' +
                '}';
    }

    public void setMethods(Method[] methods) {
        this.methods = methods;
    }

    public Method[] getMethods() {
        return methods;
    }

    public void addClassMethods(Class<?> clazz, Method[] methods) {
        classMethods.put(clazz,methods);
    }

    public Map<Class, Method[]> getClassMethods() {
        return classMethods;
    }
    /*
        获取pointCut方法的方法名字
     */
    public String getPointCutMethodName() {
        return targetPointCutMethodName;
    }

    public boolean isTargetToPointCut() {
        return isTargetToPointCut;
    }

    public void setTargetToPointCut(boolean targetToPointCut) {
        isTargetToPointCut = targetToPointCut;
    }

    public void setTargetPointCutMethodName(String targetPointCutMethodName) {
        this.targetPointCutMethodName = targetPointCutMethodName;
    }
}
